function createStore(result){
	var store = Ext.create('Ext.data.JsonStore', {
		fields : ['name', 'description', 'startDateTime', 'endDateTime','value','tags'], 
		proxy : {
			type : 'memory', 
			reader : {
				type : 'json', 
				root : 'data'
			}
		}
	}); 
	
	store.loadRawData(result); 
	
	return store; 
}

function createGrid(result){
	
	var store = createStore(result); 
	
	var grid = Ext.create('Ext.grid.Panel', {
		title : "Things i did", 
		closable : true, 
		frame : true, 
		width : 600,
		renderTo : 'specificGridSummary', 
		store : store, 
		columns : [
          {header : 'Source', dataIndex : 'name'}, 
          {header : 'Description',  dataIndex : 'description'},
          {header : 'Start date',   dataIndex : 'startDateTime'}, 
          {header : 'End date',     dataIndex : 'endDateTime'},
          {header : 'Value',     dataIndex : 'value'},
          {header : 'Tags',     dataIndex : 'tags'},          
        ]
	}); 
	
	grid.show(); 
}
function createForm(){
	
	Ext.create('Ext.form.Panel', {
		renderTo : 'seeSpecificSourceForm',  
		title : 'See a particular time event ', 
		url : '/../Cafca/SeeSpecificEventServlet', 
		method : 'POST', 
		frame : true,
		height : 90, 
		width : 400, 
		items : [
	         {
	        	 xtype : 'datefield', 
	        	 format : 'Y/m/d', 
	        	 fieldLabel : 'Start date ',
	        	 name : 'date', 
	        	 allowBlank : false, 
	         }, {
	        	 xtype : 'button', 
	        	 text : 'See ', 
	        	 disabled : true, 
	 			 formBind : true,
	 			 handler : function(){
	 				var dataToSend = this.up('form').getForm(); 
					dataToSend.submit(
						{
							success:function(form, action){
								var result = Ext.JSON.decode(action.response.responseText);
								createGrid(result); 
							}, 
							
							failure:function(form, action){
								alert("Failure"); 
							}
						}
					);
	 			 }         	 	         
	         }]
	});
}

Ext.onReady(createForm); 